﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Booking_Hotel.DBML;

namespace Booking_Hotel.DAL
{
    public class Supplier_ImageDAO
    {
        ThanhBHotelDataContext tbk = new ThanhBHotelDataContext();

        public Supplier_Hotel_Image GetSupplier_Hotel_ImageByID(int ID)
        {
            return tbk.sp_Supplier_Hotel_ImageSelect(ID).SingleOrDefault();
        }

        public void addSupplier_Hotel_Image(Supplier_Hotel_Image shi)
        {
            Supplier_Hotel_Image add = new Supplier_Hotel_Image
            {
                Supplier_HotelID= shi.Supplier_HotelID  ,
                ImagePath = shi.ImagePath,
                Description= shi.Description,
                StatusAnhDaiDien= shi.StatusAnhDaiDien
            };

            tbk.Supplier_Hotel_Images.InsertOnSubmit(add);
            tbk.SubmitChanges();
        }

        public void updateSupplier_Hotel_Image(Supplier_Hotel_Image shi)
        {
            Supplier_Hotel_Image update = tbk.Supplier_Hotel_Images.Single(ca => ca.Supplier_hotel_ImageID == (int)shi.Supplier_hotel_ImageID);
            {
                update.Supplier_hotel_ImageID = shi.Supplier_hotel_ImageID;
                update.Supplier_HotelID = shi.Supplier_HotelID;
                update.ImagePath = shi.ImagePath;
                update.Description = shi.Description;
                update.StatusAnhDaiDien = shi.StatusAnhDaiDien;
            }
            tbk.SubmitChanges();
        }
    }
}